﻿@using System.Data;
@using System.Web;
@using DTcms.Web.MVC.Areas.Web.Controllers;
@using DTcms.Web.MVC.UI.Controllers;
@using DTcms.Model;
@{
   Layout = "~/Areas/Web/Views/" + ViewBag.TemplateSkin + "/mobile/Shared/_LayoutUser.cshtml";
   DTcms.Model.channel_site site = ViewData["site"] as DTcms.Model.channel_site;
   DTcms.Model.siteconfig config = ViewData["config"] as DTcms.Model.siteconfig;
   BaseController bc = ViewBag.BasePage as BaseController;
   UserController c = ViewBag.This as UserController;
   DTcms.Model.users m = c.userModel;
   ViewBag.Title = "我的订单 - " + site.name;
   string action = ViewBag.Action as string;
   DataTable list = null;
   int count = 0;
   int totalcount = 0;
   int page = int.Parse(ViewBag.Page as string);
   string pagelist = string.Empty;
   string user_avatar = string.Empty;
}
@section HeaderContent{
   <link href="~/templates/@ViewBag.TemplateSkin/mobile/css/style.css" rel="stylesheet" />
}

<div class="section clearfix">
  <div class="line30"></div>

  <div class="info-wrap">
   
    <!--右侧内容-->
    <div class="home-box">
      @if(action=="list"){
      <!--交易订单-->
      <div class="u-tab-head">
        <p>
          <a class="selected" href="@bc.linkurl("userorder","list")">交易订单</a>
          <a href="@bc.linkurl("userorder","close")">已关闭订单</a>
        </p>
      </div>
      <div class="u-tab-content">
        <div class="title-div">
          <strong>交易订单</strong>
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ftable">
          <tr>
            <th width="16%" align="left">订单号</th>
            <th align="left">订单商品</th>
            <th width="10%">姓名</th>
            <th width="12%">订单金额</th>
            <th width="11%">下单时间</th>
            <th width="10%">状态</th>
            <th width="12%">操作</th>
          </tr>
          @{ 
          list = bc.get_order_list(10, page, "user_id="+m.id+" and status<=3", out totalcount); <!--取得一个DataTable-->
          pagelist=bc.get_page_link(10, page, totalcount, "userorder", action, "__id__"); <!--取得分页页码列表-->
          foreach(DataRow dr in list.Rows){
          <tr>
            <td>@dr["order_no"]</td>
            <td>
              @{
              List<DTcms.Model.article> ls=bc.get_order_goods_list(Convert.ToInt32(dr["id"]));
              if(ls!=null){
                 foreach(DTcms.Model.article mt in ls){
                 <a target="_blank" title="@mt.title" href="@bc.linkurl("goods_show",mt.id)">
                   <img width="60" height="60" alt="@mt.title" src="@mt.img_url" class="img">
                 </a>
                 }
              }
              }
            </td>
            <td align="center">@dr["accept_name"]</td>
            <td align="center"><strong>￥@dr["order_amount"]</strong><br />@bc.get_payment_title(Convert.ToInt32(dr["payment_id"]))</td>
            <td align="center">@dr["add_time"]</td>
            <td align="center">
              @bc.get_order_status(Convert.ToInt32(dr["id"]))
            </td>
            <td align="center">
              <a href="@bc.linkurl("userorder_show",dr["id"])">查看订单</a><br />
              @if(bc.get_order_payment_status(Convert.ToInt32(dr["id"]))){
              <a href="@bc.linkurl("payment","?action=confirm&order_no="+dr["order_no"])">去付款</a> <span>|</span>
              }
              @if(Convert.ToInt32(dr["status"])<2){
              <a href="javascript:;" onclick="clickSubmit('@(config.webpath)tools/submit_ajax.ashx?action=order_cancel&order_no=@dr["order_no"]');">取消</a>
              }
            </td>
          </tr>
          }
          }
          @if(totalcount<1){
          <tr>
            <td colspan="8" align="center">暂无记录</td>
          </tr>
          }
        </table>
        <div class="page-foot">
          <div class="flickr right">@pagelist</div><!--放置页码列表-->
        </div>
      </div>
      <!--/交易订单-->
      
      }else if(action=="close"){
      <!--已关闭订单-->
      <div class="u-tab-head">
        <p>
          <a href="@bc.linkurl("userorder","list")">交易订单</a>
          <a class="selected" href="@bc.linkurl("userorder","close")">已关闭订单</a>
        </p>
      </div>
      <div class="u-tab-content">
        <div class="title-div">
          <strong>交易订单</strong>
        </div>
        
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ftable">
          <tr>
            <th width="16%" align="left">订单号</th>
            <th align="left">订单商品</th>
            <th width="10%">姓名</th>
            <th width="12%">订单金额</th>
            <th width="11%">下单时间</th>
            <th width="10%">状态</th>
            <th width="12%">操作</th>
          </tr>
          @{ 
          list = bc.get_order_list(10, page, "user_id="+m.id+" and status>3", out totalcount); <!--取得一个DataTable-->
          pagelist = bc.get_page_link(10, page, totalcount, "userorder", action, "__id__"); <!--取得分页页码列表-->
          foreach(DataRow dr2 in list.Rows){
          <tr>
            <td>@dr2["order_no"]</td>
            <td>
              @{
              List<DTcms.Model.article> ls2 = bc.get_order_goods_list(Convert.ToInt32(dr2["id"]));
              if(ls2!=null){
                 foreach(DTcms.Model.article mt in ls2){
                 <a target="_blank" title="@mt.title" href="@bc.linkurl("goods_show",mt.id)"><img width="60" height="60" alt="@mt.title" src="@mt.img_url"></a>
                 }
              }
              }
            </td>
            <td align="center">@dr2["accept_name"]</td>
            <td align="center"><strong>￥@dr2["order_amount"]</strong><br />@bc.get_payment_title(Convert.ToInt32(dr2["payment_id"]))</td>
            <td align="center">@dr2["add_time"]</td>
            <td align="center">@bc.get_order_status(Convert.ToInt32(dr2["id"]))</td>
            <td align="center"><a href="@bc.linkurl("userorder_show",dr2["id"])">查看订单</a></td>
          </tr>
          }
          }
          @if(totalcount<1){
          <tr><td colspan="8" align="center">暂无记录</td></tr>
          }
        </table>
    
        <div class="page-foot">
          <div class="flickr right">@pagelist</div><!--放置页码列表-->
        </div>
      </div>
      <!--/已关闭订单-->
      }
    </div>
    <!--/右侧内容-->
  </div>
</div>